//-----------------------------------------------------------------------
// <copyright file="Match.cs" company="Rhys Parry">
//    Copyright Rhys Parry 2009
//    This file is released under the Apache 2.0 License
// </copyright>
//-----------------------------------------------------------------------
namespace Smarts.Core.RegularExpressions
{
    using System.Collections.Generic;
    using System.Linq;
    using Stre = System.Text.RegularExpressions;

    public class Match : Group
    {
        private readonly Stre.Match match;

        private Match(Stre.Match match) : base(match)
        {
            this.match = match;
        }

        public static Match Empty
        {
            get
            {
                return Stre.Match.Empty;
            }
        }

        public IEnumerable<Group> Groups
        {
            get
            {
                return match.Groups.Cast<Group>();
            }
        }

        public Match NextMatch()
        {
            return match.NextMatch();
        }

        public string Result(string replacement)
        {
            return match.Result(replacement);
        }

        public static implicit operator Stre.Match(Match match)
        {
            return match.match;
        }

        public static implicit operator Match(Stre.Match match)
        {
            return new Match(match);
        }
    }
}